<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
              <el-button
                type="primary"
                plain
                icon="el-icon-plus"
                size="mini"
                @click="handleAdd"
                >新增</el-button
              >
            </el-col> -->

      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="menusList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="序号" align="center" type="index" width="50" />

      <el-table-column label="标题" align="center" prop="projectName">
      </el-table-column>
      <el-table-column label="公司名称" align="center" prop="companyName">
      </el-table-column>


      <!-- 0未开始 1一开始 2已结束 3已作废 -->

      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span>
            <!-- //             <el-tag>标签一</el-tag>
  // <el-tag type="success">标签二</el-tag>
  // <el-tag type="info">标签三</el-tag>
  // <el-tag type="warning">标签四</el-tag>
  // <el-tag type="danger">标签五</el-tag> -->

            <el-tag
              :type="
                scope.row.status == 0
                  ? ''
                  : scope.row.status == 1
                  ? 'info'
                  : scope.row.status == 2
                  ? 'success'
                  : 'danger'
              "
              >{{
                scope.row.status == 0
                  ? "竞标中"
                  : scope.row.status == 1
                  ? "竞标失败"
                  : scope.row.status == 2
                  ? "竞标成功"
                  : "已作废"
              }}</el-tag
            >
          </span>
        </template>
      </el-table-column>

      <el-table-column label="竞标总价" align="center" prop="allMoney">
      </el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        fixed="right"
        class-name="small-padding fixed-width"
        width="200"
      >
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="seeInfo(scope.row)">详情</el-button >
            <el-button size="mini" type="text" @click="zhuofClik(scope.row)">作废</el-button >
                <el-button size="mini" type="text" v-if="scope.row.status != 3">导出</el-button >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改菜谱对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="80%"
      append-to-body
      class="universal-from"
    >
     
      <projectLog :logId="logId" v-if="open"></projectLog>
    </el-dialog>
  </div>
</template>
        
  <script>
import { getProjectLog, editPorLog,editProLogCom } from "@/api/system/projectLog";
import projectLog from "./projectLog";
//   import record from "./orderInfo";

export default {
  components: { projectLog },
  name: "manage",
  data() {
    return {
        logId: 0,
      brand: [], //单位
      cate: [], //菜谱
      specifications: [], //规格
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 菜谱表格数据
      menusList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: null,
        title: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
    };
  },
  created() {
    // this.queryParams.cateId = this.$route.params.cid;
    this.queryParams.projectId = this.$route.params.cid
    // console.log()
    this.getList();

    // this.show();
    //   import { getFormatbrandData } from "@/api/system/brand";
    //   import { getFormatCateData } from "@/api/system/cate";
    //   import { getFormatSpecData } from "@/api/system/specifications";
  },
  methods: {
    // cancel()
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },

    /** 查询菜谱列表 */
    getList() {
      this.loading = true;
      getProjectLog(this.queryParams).then((response) => {
        this.menusList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        brandId: undefined, //单位id
        cateId: this.queryParams.cateId, //行业菜谱id
        demand: undefined, //要求
        name: undefined, //名称
        other: undefined, //其他
        packages: undefined, //包装
        parentId: -1, //上级分类id
        specId: undefined, //规格id
        id: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //作废
    zhuofClik(row) {
      this.$modal
        .confirm("是否确认作废？")
        .then(function () {
          return editProLogCom({ id: row.id, status: 3 });
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("作废成功");
        })
        .catch(() => {});
    },
    seeInfo(row) {
      console.log(row);
      this.open = true;
      this.title = row.companyName;
      this.logId = row.id;
      // getDoseInfoManage({ id: row.id }).then((response) => {
      //   console.log(response);
      // });
    },
  },
};
</script>
        